export const exportTable = (table, fileName) => {
  const html = `<html><head><meta charset='utf-8' /></head><body>${table}</body></html>`;
  const aTag = document.createElement('a');
  const blob = new Blob([html], { type: 'application/vnd.ms-excel' });
  aTag.download = `${fileName ? fileName : new Date().getTime()}.xls`;
  aTag.href = URL.createObjectURL(blob);
  aTag.click();
  URL.revokeObjectURL(blob);
};

export const renderTable = (header, body) => {
  const tHeader = header.map(item => {
    return (<th>Email</th>);
  });

  const tBody = body.map(val => {
    return (
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
    );
  });
  return `<table border="1" align="center">
  <thead>
    <tr>
      ${tHeader}
    </tr>
  </thead>
  <tbody>
    ${tBody}
  </tbody>
</table>`;
};
